<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>FileGetAttrib</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileGetAttrib</h1>

<p>Reports whether a file or folder is read-only, hidden, etc.</p>

<pre class="Syntax">FileGetAttrib, OutputVar [, Filename]
<a href="FileGetAttrib.htm#attrib">AttributeString</a> := <a href="../Functions.htm#FileExist">FileExist</a>(FilePattern)</pre>
<h3>Parameters</h3>
<dl>

  <dt>OutputVar</dt>
  <dd><p>The name of the variable in which to store the retrieved text.</p></dd>

  <dt>Filename</dt>
  <dd><p>The name of the target file, which is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified. If omitted, the current file of the innermost enclosing <a href="LoopFile.htm">File-Loop</a> will be used instead.</p></dd>

</dl>
<h3>ErrorLevel</h3>
<p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if there was a problem or 0 otherwise.</p>
<p><a href="../Variables.htm#LastError">A_LastError</a> is set to the result of the operating system's GetLastError() function.</p>

<h3>Remarks</h3>
<p><a name="attrib"></a>The string returned will contain a subset of the letters in the string &quot;RASHNDOCT&quot;:<br>
  <br>
R = READONLY<br>
A = ARCHIVE<br>
S = SYSTEM<br>
H = HIDDEN<br>
N = NORMAL<br>
D = DIRECTORY<br>
O = OFFLINE<br>
C = COMPRESSED<br>
T = TEMPORARY</p>
<p><br>
  To check if a particular attribute is present in the retrieved string, following this example:</p>
<pre>FileGetAttrib, Attributes, C:\My File.txt
IfInString, Attributes, H
    MsgBox The file is hidden.</pre>
<p>On a related note, to retrieve a file's 8.3 short name, follow this example:</p>
<pre><a href="LoopFile.htm">Loop</a>, C:\My Documents\Address List.txt
    ShortPathName = %A_LoopFileShortPath%  <em>; Will yield something similar to C:\MYDOCU~1\ADDRES~1.txt</em></pre>
<p>A similar method can be used to get the long name of an 8.3 short name.</p>
<h3>Related</h3>
<p><a href="../Functions.htm#FileExist">FileExist()</a>, <a href="FileSetAttrib.htm">FileSetAttrib</a>, <a href="FileGetTime.htm">FileGetTime</a>, <a href="FileSetTime.htm">FileSetTime</a>, <a href="FileGetSize.htm">FileGetSize</a>, <a href="FileGetVersion.htm">FileGetVersion</a>, <a href="LoopFile.htm">File-loop</a></p>
<h3>Example</h3>
<pre class="NoIndent">FileGetAttrib, OutputVar, C:\New Folder</pre>

</body>
</html>
